package com.ticket.system.mapper;

import java.math.BigDecimal;
import java.util.List;

import com.ticket.system.domain.YanchuOrder;
import com.ticket.system.domain.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 订单Mapper接口
 *
 * @author ruoyi
 * @date 2023-09-26
 */
public interface YanchuOrderMapper {
    /**
     * 查询订单
     *
     * @param id 订单主键
     * @return 订单
     */
    public YanchuOrder selectYanchuOrderById(Long id);

    public YanchuOrder selectOrderById(Long id);

    public YanchuOrder selectYanchuOrderByNo(@Param("orderNo")String orderNo);

    public OrderVo selectOrderVoById(Long orderId);

    /**
     * 查询订单列表
     *
     * @param yanchuOrder 订单
     * @return 订单集合
     */
    public List<YanchuOrder> selectYanchuOrderList(YanchuOrder yanchuOrder);

    public List<YanchuOrderVO> selectOrderList(QueryOrderListVO query);

    List<BigDecimal> getOrderStatistics(QueryOrderListVO query);

    List<BigDecimal> getBackendOrderStatistics(QueryOrderListVO query);

    public List<OrderTicketVO> getTicketNum(String orderId);

    public List<OrderVo> selectUserOrderVoList(YanchuOrder yanchuOrder);

    public List<OrderVo> selectUserReminderOrderVoList(YanchuOrder yanchuOrder);

    public List<OrderVo> selectPayedOrderVoList(@Param("sessionId") Long sessionId,@Param("ticketType") Integer ticketType);

    /**
     * 新增订单
     *
     * @param yanchuOrder 订单
     * @return 结果
     */
    public int insertYanchuOrder(YanchuOrder yanchuOrder);

    /**
     * 修改订单
     *
     * @param yanchuOrder 订单
     * @return 结果
     */
    public int updateYanchuOrder(YanchuOrder yanchuOrder);
    //修改欠款信息
    public int updateYanchuOrderPay(YanchuOrder yanchuOrder);

    public int updateOrderStatus(@Param("orderNo") String orderNo,@Param("transactionId") String transactionId,
                                 @Param("status") Integer status, @Param("oldStatus") Integer oldStatus);
    public int updateOrderPayStatus(@Param("orderNo") String orderNo,@Param("transactionId") String transactionId,
                                 @Param("status") Integer status, @Param("oldStatus") Integer oldStatus);
    /**
     * 删除订单
     *
     * @param id 订单主键
     * @return 结果
     */
    public int deleteYanchuOrderById(Long id);

    /**
     * 批量删除订单
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteYanchuOrderByIds(Long[] ids);

    public List<YanchuOrder> selectExpireOrderList();

    /**
     * 修改超时订单
     *
     * @return
     */
    public int updateExpireOrder(@Param("orderId") Long orderId, @Param("status") Integer status, @Param("oldStatus") Integer oldStatus);

    /**
     * 查询订单列表
     *
     * @return 订单集合
     */
    public List<OrderVo> selectYanchuOrderPageList(@Param("deptId") Long deptId,
                                                   @Param("performId") Long performId,
                                                   @Param("sessionId") Long sessionId,
                                                   @Param("orderStatus") Integer orderStatus,
                                                   @Param("orderId") String orderId,
                                                   @Param("ticketBuyer") String ticketBuyer,
                                                   @Param("phone") String phone);
    public int updateRefundById(@Param("id") Long id, @Param("status") Integer status,
                                @Param("oldStatus") Integer oldStatus,@Param("refundNo") String refundNo,@Param("userId") Long userId,
                                @Param("cardRefundAmt") BigDecimal cardRefundAmt,@Param("balanceRefundAmt") BigDecimal balanceRefundAmt,
                                @Param("wechatRefundAmt") BigDecimal wechatRefundAmt);

    int checkOrderStatus(Long sessionId);

    public DetailInfoVO getDetailInfo(String orderId);

    public TicketInfoVO getTicketDetail(String orderId);

    int updateRefundAmtById(@Param("id") Long id,
                            @Param("cardRefundAmt") BigDecimal cardRefundAmt,
                            @Param("balanceRefundAmt") BigDecimal balanceRefundAmt,
                            @Param("wechatRefundAmt") BigDecimal wechatRefundAmt);


    List<SettleGroupVO> getSettleGroupList(@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("deptIds")List<Long> ids);
    List<SettleGroupDetailVO> getSettleGroupDetail(@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("deptIds")List<Long> ids);
    List<MemberStatisticsVO> getMemberStatistics(@Param("startTime")String startTime,@Param("endTime")String endTime);
}
